<?php
header('Content-Type: text/html; charset=UTF-8');

if(!defined('INC_PATH')){
	define("INC_PATH","../../../");
}
require_once(INC_PATH."lib_new/db.php");
$member_id = $_COOKIE['sav_memberid'];
$sql_del = "
DELETE
FROM smd_takarakuji_see
WHERE member_id = $member_id
AND date_trunc('month',regist_date) = date_trunc('month',now())
";
$con = con_open();

$res_del = pg_query($con, $sql_del);
if($res_del){
		$sql = "
		UPDATE smd_takarakuji_get
		SET flag=0
		WHERE member_id=$member_id
		AND flag>0
		AND prize = 0
		";
		$res = pg_query($con, $sql);
		if($res){
			echo $member_id."のハズレフラグをクリアしました";
		}
	}
	
con_close($con);

?>